<?php
include_once '../header1.php';
?>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","upp_sch_names.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{
document.DelSch.SchName.value=val;
document.getElementById("List").innerHTML="";
}
</script>
<script type="text/javascript">
function DeleteVerification()
{
<?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   
   else
   {
   ?>
var Census_Number=document.forms["DelSch"]["SchName"].value;
if (Census_Number=="")
  {
  alert("Please select the School's name to delete!");
  return false;
  }
  
if (Census_Number!="")
{
var r=confirm("Are you sure to delete this?");
if (r==true)
  {
  return true;
 
 }

if(r==false)
  {
 return false;
  }
}
}

</script>
</head>
<body>
 
<?php
include_once ("../header2.php");
?>
<?php
include_once "topmenu.php";
?>
<div id="content">
	<div id="main">
	  <div id="bodyfield">
 <div id="lefttablereg">
<form  name="DelSch" action="#" method="POST" onSubmit="return DeleteVerification()">
<?php
if(isset($_POST['Delete']))
{
require_once 'DEL.php';
}
?>
  <table width="562" border="0" class="tablefontv">
    <tr>
      <td height="21" colspan="5"  scope="row" class="err">
        <?php
      if(isset($_POST['Delete']))
{
	if(isset($_SESSION['error']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errorin']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['errornorow']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
	if(isset($_SESSION['errornot']))
	{echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornot'];
		unset($_SESSION['errornot']);
	}
	 if(isset($_SESSION['errornot2']))
	{
echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornot2'];
		unset($_SESSION['errornot2']);
	}
}   
?>
</td>
</tr>
    <tr>
      <th width="47" height="41" align="left" scope="row" bgcolor="#6AB5FF">&nbsp;</th>
      <th width="190" align="left" scope="row" bgcolor="#6AB5FF"><label>School's Name</label></th>
      <th width="12" align="left" scope="row" bgcolor="#6AB5FF">:-</th>
      <td width="123" bgcolor="#999999"><label for="select"></label>
        <?php
	 	if($_SESSION['Access_Type']=="Teacher in Charge")
{
	$NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id']; 
    $snam=mysql_query("SELECT * FROM school WHERE School_Id='$Own_School_Id'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
}
	 echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' size='40' readonly='readonly'/>";
}
	else if($_SESSION['Access_Type']=="Administrator")
{
	if(!isset($SchName))
	{
		$snam=mysql_query("SELECT * FROM school WHERE School_Id='$School_Id1'");
	  if($ros=mysql_fetch_array($snam))
	  {
	  $SchName=$ros['Name'].','.$ros['Address'];
	  }
	}
	    echo "<input type='text' id='SchName' name='SchName' onKeyUp='showHint(this.value)' value='$SchName' size='40'/>";
}
	  ?></td>
      <td width="168" bgcolor="#6AB5FF">&nbsp;</td>
    </tr>
  </table>
  
  <a href="DelSch.php" class="reset">Reset |</a>
  <input name="Delete" align="middle" type="submit" value="Delete" class="buttonok"/>
  <br/>
  </form>
 <?php
 if(isset($_POST['Delete']))
{

	 if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
   {
	  echo '<br>';
	  if($Census_Number!=""&&$School_Id!=""&&$Name!="")
	  {
  echo '<table width="300" class="tablefontv">';
   echo'<tr>';
     echo '<th>';
	 echo "Principal Name";
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $Principal_Name;
	echo '</td>';
	 echo '<th></th>';
    echo '<th></th>';
    echo '<td></td>';
     echo '<th></th>';
    echo '<th></th>';
    echo '<td></td>';
    echo '</tr>';
 echo'<tr>';
     echo '<th>';
	 echo "School ID";
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $School_Id;
	echo '</td>';
	 echo '<th>'.'Account Number'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Account_Number.'</td>';
     echo '<th>'.'Web Address'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Web_Address.'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>';
	 echo 'School Name';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $Name;
	echo '</td>';
	   echo '<th>'."Telephone Number".'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Tp_Number.'</td>';
	echo '<th>'.'Medium'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Medium.'</td>';
    echo '</tr>';
	echo'<tr>';
	echo '<th>'.'Email Address'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$E_Mail.'</td>';
     echo '<th>'.'Fax Number'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Fax_Number.'</td>';
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>';
	 echo 'School Address';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $Address;
	echo '</td>';
	echo '<th>'.'Grade Range'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Grade_Range.'</td>';
	   
    echo '</tr>';
	echo'<tr>';
     echo '<th>';
	 echo 'Division';
	 echo '</th>';
    echo '<th>';
	echo ':-';
	echo '</th>';
    echo '<td>';
	echo $Division;
	echo '</td>';
	 echo '<th>'.'School Type'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Type.'</td>';
  
    echo '</tr>';
	
	 echo'<tr>';
     echo '<th>'.'District'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$District.'</td>';
	   echo '<th>'.'School Status'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Status.'</td>';
    echo '</tr>';
	echo'<tr>';
     echo '<th>'.'Province'.'</th>';
    echo '<th>'.':-'.'</th>';
    echo '<td>'.$Province.'</td>';
    echo '</tr>';
  echo '</table>';
  }
}
}
 ?>
 </div>
 <div id="righttablereg">
  <div class="suggestionListsch" id="List"></div>
 </div>
  </div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">SCHOOLS</h2>
            </div> 
     <?php
include_once "menu.php";
?>
 <?php
include_once ("../footer.php");

?>
<?php
}
?>
</body>
</html>